package com.fcmeditech.AsianSexyGirls.adwhirl;

import android.app.Activity;
import android.widget.LinearLayout;
import android.widget.TableRow.LayoutParams;

import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlTargeting;

public class AdManager {

	private static AdManager _instance;

	public static AdWhirlLayout adWhirlLayout;
	public static LinearLayout parentview;
	public static LinearLayout.LayoutParams adWhirlLayoutParams;
	public static boolean AdwhirlInit = false;

	static synchronized public AdManager getInstance() {
		if (_instance == null) {
			_instance = new AdManager();
		}
		return _instance;
	}

	private AdManager() {}

	public static void initAdManager(Activity act, String key) {
		if(!AdwhirlInit) {
			AdWhirlTargeting.setKeywords("news reader magazine information weather book rss");
			
			//AdWhirlManager.setConfigExpireTimeout(-1);

			adWhirlLayout = new AdWhirlLayout(act, key);
			adWhirlLayout.setAdWhirlInterface(new AdwhirlCustomEvents(act));
			adWhirlLayoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

			AdwhirlInit = true;
		}
	}

	public static void addtoParent(LinearLayout parent) {
		if(parentview != null) {
			parentview.removeAllViews();
		}
		parent.addView(adWhirlLayout, adWhirlLayoutParams);
		parentview=parent;
	}
}
